{extend name="public:base"}
{block name="body"}
<body class="pear-container">
	<div class="layui-card">
		<div class="layui-card-body">
			<form class="layui-form" action="">
                <div class="layui-form-item layui-inline">
                    <label class="layui-form-label">订单</label>
                    <div class="layui-input-inline">
                        <input type="text" name="keywords" placeholder="订单号|交易号|会员手机号" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-inline">
                    <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="table-query">
                        <i class="layui-icon layui-icon-search"></i>
                        查询
                    </button>
                    <button type="reset" class="pear-btn pear-btn-md">
                        <i class="layui-icon layui-icon-refresh"></i>
                        重置
                    </button>
                </div>
			</form>
		</div>
	</div>
	<div class="layui-card">
		<div class="layui-card-body">
			<table id="table-list" lay-filter="table-list"></table>
		</div>
	</div>
</body>
{/block}
{block name="custome"}
	<script type="text/html" id="table-toolbar">
        <!--button class="pear-btn pear-btn-primary pear-btn-md" lay-event="explode">
			<i class="layui-icon layui-icon-add-1"></i>
			导出
		</button-->
		
	</script>
	<script type="text/html" id="table-bar">
		<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="detail" title="查看订单"><i class="icon pear-icon pear-icon-browse"></i></button>
	</script>
	{/block}
{block name="script"}

<script type="text/html" id="table-status">
    {{# if (d.status == 1){ }}
        待支付
    {{# } }}
    {{# if (d.status == 2){ }}
        {{# if(d.is_refund==1){ }}
        <span style="color:#f00;">订单退款</span>
        {{# }else{ }}
        已支付
        {{# } }}
    {{# } }}
    
</script>
<script type="text/html" id="table-create_time">
        {{layui.util.toDateString(d.create_time, 'yyyy-MM-dd HH:mm')}}
</script>

<script type="text/html" id="table-sale_price">
    <span>¥{{ d.price }}</span>
</script>

<script type="text/html" id="table-order_price">
    <span>¥{{ d.order_price }}</span>
</script>
<script type="text/html" id="table-pay_type">
    {{# if (d.pay_status == 1 ){ }}
        微信支付
    {{# }else{ }}
        线下支付
    {{# } }}
</script>
<script type="text/html" id="table-pay_status">
    {{# if (d.pay_status == 1 ){ }}
        已付款
    {{# }else{ }}
        未支付
    {{# } }}
</script>
<script type="text/html" id="table-pay_time">
    {{# if (d.pay_time ){ }}
    {{layui.util.toDateString(d.pay_time, 'yyyy-MM-dd HH:mm')}}
    {{# } }}
</script>
<script>
    layui.use(['table', 'form', 'jquery', 'common','layer'], function () {
        let table = layui.table;
        let form = layui.form;
        let $ = layui.jquery;
        let common = layui.common;
        let layer = layui.layer;
        let cols = [
            [
            {
                title: '订单号',
                field: 'order_sn',
                width: 160,
                templet:'#table-sn',
                fixed:'left'
           
            },
            {
                title: '会员手机号',
                field: 'mobile',
                width:200
            },
            
            {
                title: '商品额',
                field: 'sale_price',
                align: 'center',
                templet:'#table-sale_price',
                width: 100
            },
            
            {
                title: '订单总额',
                field: 'order_price',
                align: 'center',
                templet:'#table-order_price',
                width: 100
               
            },
            
            {
                title: '支付方式',
                field: 'pay_type',
                align: 'center',
                templet:'#table-pay_type',
                width: 100
               
            },
            {
                title: '支付交易号',
                field: 'transaction_id',
                align: 'center',
                width: 180
               
            },
            {
                title: '支付状态',
                field: 'pay_status',
                align: 'center',
                templet:'#table-pay_status',
                width: 100
               
            },           
            {
                title: '状态',
                field: 'status',
                align: 'center',
                templet: '#table-status',
                width: 100
                
            },
            {
                title: '操作',
                toolbar: '#table-bar',
                width:185,
                fixed:'right'
   
            }]
        ]
        $(document).on('click','.thumb',function(){
            var src = $(this).find('img').attr('src');
 
            layer.open({
                type: 1,
                title: false,
                shade: 0.8,
                closeBtn: 0,
                shadeClose: true,
                content: '<img src="'+src+'">'
            });
        })

        table.render({
            elem: '#table-list',
            url: '{:url("index")}',
            parseData: function(res){ 
            return {
            "code": res.code, //解析接口状态
            "msg": res.message, //解析提示文本
            "count": res.data.total, //解析数据长度
            "data": res.data.data //解析数据列表
            }},
            page: true,
            cols: cols,
            skin: 'line',
            toolbar: '#table-toolbar',
            defaultToolbar: [{
                title: '刷新',
                layEvent: 'refresh',
                icon: 'layui-icon-refresh',
            }, 'filter']
        });
        form.on('submit(table-query)', function (data) {
            table.reload('table-list', {
                where: data.field
            })
            return false;
        });
        table.on('tool(table-list)', function (obj) {
            
            if (obj.event === 'detail') {
                common.modalo('{:url("edit")}?ids=' + obj.data['id'],'订单查看','520px');
            }
            
        });
        
    })
</script>
{/block}